import requests
import os
from os.path import exists


class CAT(object):

    def download_cat(self):
        a = int(input("Please enter the length you want:"))
        b = int(input("Please enter the width you want:"))
        url = f'http://placekitten.com/g/{a}/{b}'
        response = requests.get(url)
        cat_img = response.content
        if not exists('CatData'):
            os.mkdir('CatData')
        name = str(f'CatData/cat_{a}_{b}.jpg')
        with open(name, 'wb',) as f:
            f.write(cat_img)
        f.close()


if __name__ == "__main__":

    cat = CAT()
    cat.download_cat()